/*
 * Copyright © 2011 PCCW Solutions All right reserved.
 *
 */
package com.blues.framework.db;

import java.util.Map;
import java.util.Vector;
import org.apache.commons.lang.math.NumberUtils;

/**
 * 数据库批脚本
 * 
 * @author: Kyle.Zhang 2011-9-26 12:19:41
 */
public class BatchSQL {
	/** 定义查询sql */
	public final static String QUERY_CONFIG_SQL = "select t.BATCH_NAME, t.SQL_TEXT, t.SQL_TYPE, t.BATCH_COUNT, t.MAX_IDLE_TIME from cper.hades_db_batch t";

	/** 批处理名称 */
	private String name;
	/** 批处理SQL脚本内容 */
	private String sql;
	/** 批处理脚本类型，SQL类型，SQL：无参SQL，SQL-PARAM：带参数SQL，PROC：无参数过程，PROC-PARAM：带参数过程 */
	private String type;
	/** 一次批处理条数 */
	private int batchCount;
	/** 最大空闲时间 */
	private int maxIdleTime;
	/** 最后执行时间(毫秒) */
	private long lastTimeMillis;
 
	public BatchSQL() {
	}

	public BatchSQL(Map map) {
		this((String)map.get("BATCH_NAME"), 
			(String)map.get("SQL_TEXT"), 
			(String)map.get("SQL_TYPE"), 
			NumberUtils.toInt(map.get("BATCH_COUNT").toString(), 1000), 
			NumberUtils.toInt(map.get("MAX_IDLE_TIME").toString(), 60));
	}

	public BatchSQL(String name, String sql, String type, int batchCount, int maxIdleTime) {
		this.name = name;
		this.sql = sql;
		this.type = type;
		this.batchCount = batchCount;
		this.maxIdleTime = maxIdleTime;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public int getBatchCount() {
		return batchCount;
	}
	public void setBatchCount(int batchCount) {
		this.batchCount = batchCount;
	}
	public int getMaxIdleTime() {
		return maxIdleTime;
	}
	public void setMaxIdleTime(int maxIdleTime) {
		this.maxIdleTime = maxIdleTime;
	}
	
	public long getLastTimeMillis() {
		return lastTimeMillis;
	}
	public void setLastTimeMillis(long lastTimeMillis) {
		this.lastTimeMillis = lastTimeMillis;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "BatchSQL [name=" + name + ", sql=" + sql + ", type=" + type
				+ ", batchCount=" + batchCount + ", maxIdleTime=" + maxIdleTime
				+ ", lastTimeMillis=" + lastTimeMillis + "]";
	}

	
}
